/**
 * @file crypt.h
 * @brief Macros of the file functions.
 * @date Out-2011
 * @author Leonardo Lino 2101101
 * @author Joaquim Ferreira 2101104
 * @version 1.0
 */

#ifndef FILES_H
#define FILES_H

#define MY_FOPEN(filename, mode) my_fopen((filename),(mode))

/** @brief This global integer variable (G_proc_files) will contain the number of processed files.*/
extern int G_proc_files;

/**
 * @brief This function opens a file and check for errors.
 * @fn FILE *my_fopen(const char *filename, const char *mode)
 * @param filename The filename.
 * @param mode The mode to open the file.
 * @return Return a FILE type pointer or in the case of error it returns NULL.
 */
FILE *my_fopen (const char *filename, const char *mode);

/**
 * @brief Function that verifies if the filename has the termination ".xxx" eg. ".pdf" or ".txt".
 * @fn int check_file_type(char *filename, char *type)
 * @param filename A pointer to the filename.
 * @param type A pointer to the type of the filename (".xxx").
 * @return Return 1 if it matchs, otherwise it return 0.
 */
int check_file_type (char *filename, char *type);

/**
 * @brief Function that convert the pdf file to txt file using the pdftotext aplication.
 * @fn char* convert_pdf(char *filename)
 * @param filename A pointer to the filename.
 * @return Return the pointer to the string that holds the name of the text file, otherwise in case of error return Null.
 */
char *convert_pdf (char *filename);

/**
 * @brief Function that will remove the created text file that was convert from the pdf file.
 * @fn void rem_filetxt(char *filetxt)
 * @param filetxt A pointer to the filename.
 * @return Nothing to return.
 */
void rem_filetxt (char *filetxt);

#endif /* FILES_H */
